#include "fragmentshader.h"

#include <iostream>

using namespace std;

namespace GL
{


FragmentShader::FragmentShader(const std::string& shader, bool isFilename)
: Shader(shader, isFilename)
{
}


FragmentShader::~FragmentShader()
{
}

bool FragmentShader::compile()
{
    const char* shaderChar = m_ShaderContents.c_str();
    
    m_ShaderId = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(m_ShaderId, 1, &shaderChar, NULL);
    glCompileShader(m_ShaderId);

    GLint success;
    glGetShaderiv(m_ShaderId, GL_COMPILE_STATUS, &success);
    if (GL_FALSE == success)
    {
        cerr << "Shader could not be compiled" << endl;
        return false;
    }
    
    glAttachShader(m_ProgramObject, m_ShaderId);
    
    return link();
}

}
